]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
st/theme-context: Also remove theme nodes on stylesheet changes
authorJonas Dreßler <verdre@v0yd.nl>
Sat, 25 Apr 2020 11:17:13 +0000 (13:17 +0200)
committerFlorian Müllner <florian.muellner@gmail.com>
Tue, 28 Apr 2020 19:53:58 +0000 (19:53 +0000)
StThemeNodes are built around the assumption that they're "immutable",
that means they are created once with certain parameters (that resolve
to certain css properties) and then replaced with new ones in case those
parameters changed.

Changes to the internal information stored by theme nodes (i.e. the css
properties, font names or the cached scale-factor) are not all handled
the same though: For changes to the font or the scale-factor we remove
all theme nodes from the cache and let the widgets which are on stage
generate new theme nodes. For changes to the css properties/the
stylesheet, we invalidate the properties of all theme nodes but keep
them in the cache using `_st_theme_node_reset_for_stylesheet_change()`.

So be a bit more consistent and handle changes to the css-properties/the
stylesheet stored by StThemeNodes the same way as changes to the font or
scale-factor.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1218

src/st/st-theme-context.c
src/st/st-theme-node-private.h
src/st/st-theme-node.c

index 55e856f265fbaade0a88600350a4104312ee3f42..f10737b803986863ef986fc0caa620ad2ad67207 100644 (file)
@@ -290,22 +290,6 @@ on_icon_theme_changed (StTextureCache *cache,
   g_source_set_name_by_id (id, "[gnome-shell] changed_idle");
 }
 
-static void
-on_custom_stylesheets_changed (StTheme        *theme,
-                               StThemeContext *context)
-{
-  GHashTableIter iter;
-  StThemeNode *node;
-
-  if (context->root_node)
-    _st_theme_node_reset_for_stylesheet_change (context->root_node);
-
-  g_hash_table_iter_init (&iter, context->nodes);
-
-  while (g_hash_table_iter_next (&iter, (gpointer *) &node, NULL))
-    _st_theme_node_reset_for_stylesheet_change (node);
-}
-
 /**
  * st_theme_context_get_for_stage:
  * @stage: a #ClutterStage
@@ -358,9 +342,10 @@ st_theme_context_set_theme (StThemeContext          *context,
       if (context->theme)
         {
           context->stylesheets_changed_id =
-            g_signal_connect (context->theme, "custom-stylesheets-changed",
-                              G_CALLBACK (on_custom_stylesheets_changed),
-                              context);
+            g_signal_connect_swapped (context->theme,
+                                      "custom-stylesheets-changed",
+                                      G_CALLBACK (st_theme_context_changed),
+                                      context);
         }
 
       st_theme_context_changed (context);
index dedb3cc8f9c6b5329142cdd785c938052ec93e9e..7533482616b9b52245d70ebc888ae2929320a336 100644 (file)
@@ -125,7 +125,6 @@ void _st_theme_node_ensure_background (StThemeNode *node);
 void _st_theme_node_ensure_geometry (StThemeNode *node);
 void _st_theme_node_apply_margins (StThemeNode *node,
                                    ClutterActor *actor);
-void _st_theme_node_reset_for_stylesheet_change (StThemeNode *node);
 
 G_END_DECLS
 
index 85e5dbe418cb4dc283a45b2ee52cf529fab359f8..ca9675895b950019b593e5c3bc846408b4b3389a 100644 (file)
@@ -77,13 +77,6 @@ maybe_free_properties (StThemeNode *node)
     }
 }
 
-void
-_st_theme_node_reset_for_stylesheet_change (StThemeNode *node)
-{
-  maybe_free_properties (node);
-  node->properties_computed = FALSE;
-}
-
 static void
 st_theme_node_dispose (GObject *gobject)
 {